import openpyxl
wb = openpyxl.load_workbook('/Users/zhangxiangbin/招商局资本管理有限责任公司_I017-2022-01-2022-06_2022年1-6月计提账单.xlsx')
ws = wb['成本核算（明细）']

# 获取一列
colC = ws['C']
for cell in colC:
    print(cell.value)

# 获取多列
col_range = ws['C:D']
for col in col_range:
    for cell in col:
        print(cell.value)

# 获取一行
row10 = ws[10]

# 获取多行
row_range = ws[5:10]

# 遍历行
for row in ws.iter_rows(min_row=1, max_col=3, max_row=2):
    for cell in row:
        print(cell)

# 遍历列
for col in ws.iter_cols(min_row=1, max_col=3, max_row=2):
    for cell in col:
        print(cell)

# 仅遍历值
for value_row in ws.values:
    for value_cell in value_row:
        print(value_cell)

# 仅遍历值
for row in ws.iter_rows(min_row=1, max_col=3, max_row=2, values_only=True):
    print(row)
